package nbn.android.myyoutubeclient.parse;

import nbn.android.myyoutubeclient.object.UserObject;
import nbn.android.myyoutubeclient.object.VideoObject;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import android.util.Log;

public class ParserUser {
	/** --------------------- Movie Search TAG --------------------- */
	private static final String TAG_USERNAME = "yt:username";
	private static final String TAG_MEDIA_THUMB = "media:thumbnail";
	private static final String TAG_CHANNEL_ID = "yt:channelId";
//	private static final String TAG_GOOGLEPLUS_ID = "yt:googlePlusUserId";
//	private static final String TAG_FIRSTNAME = "yt:firstName";
//	private static final String TAG_LASTNAME = "yt:lastName";
	private static final String TAG_VIEW = "yt:statistics";
	private static final String TAG_USERID = "yt:userId";

	/** ---------------------Movie Attribute tags--------------------- */
	private static final String ATR_SUBSCRIBER = "subscriberCount";
	private static final String ATR_DISPLAY = "display";
	
	public static UserObject getResult(NodeList searchresult) {
		UserObject result = new UserObject();
		try {

			Element e = (Element) searchresult.item(0);
			String title = Parser.getAttributeValue(e, TAG_USERNAME, ATR_DISPLAY);
			String userid = Parser.getValue(e, TAG_USERID);
//			String firstname = Parser.getValue(e, TAG_FIRSTNAME);
//			String lastname = Parser.getValue(e, TAG_LASTNAME);
			String image_url=Parser.getImageUrlAttributeValue(TAG_MEDIA_THUMB, e);
			String channelid = Parser.getValue(e, TAG_CHANNEL_ID);
			String subscriber = Parser.getAttributeValue(e, TAG_VIEW, ATR_SUBSCRIBER);
			
			result.settitle(title);
			result.setuserid(userid);
			result.setthumbnail(image_url);
			result.setchannelid(channelid);
			result.setsubscriber(subscriber);
//			result.showinfo();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}